﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdGsLayoutHelper : OdGsDevice
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsLayoutHelper(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdGsLayoutHelper_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsLayoutHelper obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGsLayoutHelper()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdGsLayoutHelper(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGsLayoutHelper cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdGsLayoutHelper_cast(OdRxObject.getCPtr(pObj));
			OdGsLayoutHelper result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsLayoutHelper)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsLayoutHelper)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsLayoutHelper)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdGsLayoutHelper_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdGsLayoutHelper_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdGsLayoutHelper_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdGsLayoutHelper createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdGsLayoutHelper_createObject();
			OdGsLayoutHelper result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsLayoutHelper)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsLayoutHelper)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsLayoutHelper)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdDbObjectId layoutId()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr cPtr = TD_DbPINVOKE.OdGsLayoutHelper_layoutId(this.swigCPtr);
			OdDbObjectId result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbObjectId(cPtr, true));
				result = new OdDbObjectId(cPtr, false);
			}
			else
			{
				result = new OdDbObjectId(cPtr, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGsView activeView()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdGsLayoutHelper_activeView(this.swigCPtr);
			OdGsView result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsView)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsView)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsView)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void makeViewActive(OdGsView pView)
		{
			TD_DbPINVOKE.OdGsLayoutHelper_makeViewActive(this.swigCPtr, OdGsView.getCPtr(pView));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual OdGsModel gsModel()
		{
			OdGsModel result = (OdGsModel)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdGsLayoutHelper_gsModel(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdGsDevice underlyingDevice()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdGsLayoutHelper_underlyingDevice(this.swigCPtr);
			OdGsDevice result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsDevice)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsDevice)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsDevice)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool setActiveViewport(OdGePoint2d screenPt)
		{
			bool result = TD_DbPINVOKE.OdGsLayoutHelper_setActiveViewport__SWIG_0(this.swigCPtr, OdGePoint2d.getCPtr(screenPt));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool setActiveViewport(OdDbObjectId id)
		{
			bool result = TD_DbPINVOKE.OdGsLayoutHelper_setActiveViewport__SWIG_1(this.swigCPtr, OdDbObjectId.getCPtr(id));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void restoreGsViewDbLinkState()
		{
			TD_DbPINVOKE.OdGsLayoutHelper_restoreGsViewDbLinkState(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool supportLayoutGsStateSaving()
		{
			bool result = TD_DbPINVOKE.OdGsLayoutHelper_supportLayoutGsStateSaving(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool storeLayoutGsState(OdStreamBuf pStream, uint nFlags)
		{
			bool result = TD_DbPINVOKE.OdGsLayoutHelper_storeLayoutGsState__SWIG_0(this.swigCPtr, OdStreamBuf.getCPtr(pStream), nFlags);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool storeLayoutGsState(OdStreamBuf pStream)
		{
			bool result = TD_DbPINVOKE.OdGsLayoutHelper_storeLayoutGsState__SWIG_1(this.swigCPtr, OdStreamBuf.getCPtr(pStream));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static bool extractLayoutIdForGsState(OdStreamBuf pStream, OdDbDatabase pDb, OdDbObjectId layoutObjId, uint nFlags)
		{
			bool result = TD_DbPINVOKE.OdGsLayoutHelper_extractLayoutIdForGsState__SWIG_0(OdStreamBuf.getCPtr(pStream), OdDbDatabase.getCPtr(pDb), OdDbObjectId.getCPtr(layoutObjId), nFlags);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static bool extractLayoutIdForGsState(OdStreamBuf pStream, OdDbDatabase pDb, OdDbObjectId layoutObjId)
		{
			bool result = TD_DbPINVOKE.OdGsLayoutHelper_extractLayoutIdForGsState__SWIG_1(OdStreamBuf.getCPtr(pStream), OdDbDatabase.getCPtr(pDb), OdDbObjectId.getCPtr(layoutObjId));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool restoreLayoutGsState(OdStreamBuf pStream, uint nFlags)
		{
			bool result = TD_DbPINVOKE.OdGsLayoutHelper_restoreLayoutGsState__SWIG_0(this.swigCPtr, OdStreamBuf.getCPtr(pStream), nFlags);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool restoreLayoutGsState(OdStreamBuf pStream)
		{
			bool result = TD_DbPINVOKE.OdGsLayoutHelper_restoreLayoutGsState__SWIG_1(this.swigCPtr, OdStreamBuf.getCPtr(pStream));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
